<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--bootstrap插件-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link href="/static/plugin/bootstrap/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="/static/plugin/jo/joUI.css" rel="stylesheet"/>
    <!--字体插件-->
    <link href="/static/plugin/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
    <link href="/static/plugin/layui-2.4.3/css/layui.css" rel="stylesheet"/>
    <!--ztree-->
    <link href="/static/plugin/zTree/css/metroStyle/metroStyle.css" rel="stylesheet"/>
    <!--common-->
    <link href="/static/css/common.css" rel="stylesheet"/>
    <title>投票主信息表单</title>
    <style>
        .young-form-input-block{
            overflow: auto;
            word-break: break-all;
        }
        .young-form-item{
            border: #cccccc solid 1px;
        }
        .young-form-label{
            width: 111px;
            margin-right: -1px;
            border-right: #cccccc solid 1px;

        }
        .young-form-input-block{
            min-height: 35px;
            padding: 0px 5px 5px;
            border-left: #cccccc solid 1px;
        }
    </style>
</head>
<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
            <form id="pageForm" name="pageForm" action="" method="post">
                <div style="border: #cccccc solid 1px;padding: 5px;">
                    <div class=" col-md-12" style="text-align: center;font-weight: 700;">
                        <span class="jo-form-txt" name="title"></span>
                    </div>
                    <div class=" col-md-12 " style="text-align: center;">
                        （<span class="jo-form-txt" name="startTime"></span>
                        ~
                        <span class="jo-form-txt" name="endTime"></span>）
                    </div>
                    <div class=" col-md-12 " style="text-indent: 2em;">
                        <span class="jo-form-txt" name="content"></span>
                    </div>
                    <div class=" col-md-12 ">
                        <table class="table table-bordered table-hover table-line-auto" id="mainList" trHandle="trHandle" noHead="true">
                            <col field="optionContent" title="选项内容" width="95%" align=""  />
                        </table>
                    </div>
                </div>
                <br>


                <div class="young-form-item col-md-12 ">
                    <div class="young-form-label">投票时间</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <span class="jo-form-txt" name="voteTime"></span>
                    </div>
                </div>
                <div class="young-form-item col-md-12 ">
                    <div class="young-form-label">比特承诺数</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <span class="jo-form-txt" name="bitPromise"></span>
                    </div>
                </div>
                <div class="young-form-item col-md-12 ">
                    <div class="young-form-label">比特承诺结果</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <span class="jo-form-txt" name="bitValue"></span>
                    </div>
                </div>
                <div class="young-form-item col-md-12 ">
                    <div class="young-form-label">投票者公钥</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <span class="jo-form-txt" name="voterPublicKey"></span>
                    </div>
                </div>
                <div class="young-form-item col-md-12 ">
                    <div class="young-form-label">投票者私钥</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <span class="jo-form-txt" name="voterPrivateKey"></span>
                    </div>
                </div>
                <div class="young-form-item col-md-12 ">
                    <div class="young-form-label">盲化结果</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <span class="jo-form-txt" name="blindValue"></span>
                    </div>
                </div>

                <!--管理员-->
                <!--<div class="young-form-item col-md-12 ">
                    <div class="young-form-label">管理员公钥</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <span class="jo-form-txt" name="adminPublicKey"></span>
                    </div>
                </div>
                <div class="young-form-item col-md-12 ">
                    <div class="young-form-label">管理员私钥</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <span class="jo-form-txt" name="adminPrivateKey"></span>
                    </div>
                </div>
                <div class="young-form-item col-md-12 ">
                    <div class="young-form-label">管理员签名结果</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <span class="jo-form-txt" name="adminSignValue"></span>
                    </div>
                </div>
                <div class="young-form-item col-md-12 ">
                    <div class="young-form-label">管理员签名时间</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <span class="jo-form-txt" name="adminSignTime"></span>
                    </div>
                </div>-->

                <!--计票中心-->
                <!--<div class="young-form-item col-md-12 ">
                    <div class="young-form-label">计票中心结果值</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <span class="jo-form-txt" name="countCenterValue"></span>
                    </div>
                </div>
                <div class="young-form-item col-md-12 ">
                    <div class="young-form-label">计票中心计票时间</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <span class="jo-form-txt" name="countCenterTime"></span>
                    </div>
                </div>-->

                <div class="young-form-item col-md-12 ">
                    <div class="young-form-label">状态</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <span class="jo-form-txt" name="state"></span>
                    </div>
                </div>


            </form>
        </div>
    </div>



</div>

<!--配置信息-->
<script src="/static/js/config.js"></script>
<!--jquery-->
<script src="/static/plugin/jquery/jquery-3.3.1.js"></script>
<script src="/static/plugin/jquery/jquery.cookie.js"></script>
<!--bootstrap-->
<script src="/static/plugin/bootstrap/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<!--[if lt IE 9]>
<script src="/static/plugin/other/html5shiv.js"></script>
<script src="/static/plugin/other/respond.min.js"></script>
<![endif]-->
<!--layui-->
<script src="/static/plugin/layui-2.4.3/layui.all.js"></script>
<!--ztree-->
<script src="/static/plugin/zTree/js/jquery.ztree.all.js"></script>
<!--common-->
<script src="/static/js/common.js"></script>
<!--jo-->
<script src="/static/plugin/jo/jo.js"></script>
<script src="/static/plugin/jo/jo-adapt.js"></script>
<script src="/static/plugin/jo/jo-page-view.js"></script>
<script src="/static/plugin/jo/jo-page-form.js"></script>
<script src="/static/plugin/jo/jo-listener.js"></script>
<script type="text/javascript">
    layui.laydate.render({
        elem: '#startTime' //注册日期控件
    });
    layui.laydate.render({
        elem: '#endTime' //注册日期控件
    });
    /*layui.laydate.render({
        elem: '#createTime' //注册日期控件
    });
    layui.laydate.render({
        elem: '#updateTime' //注册日期控件
    });*/
    $(function(){
        var jParams = {
            "PKName" : "id",//主键属性名
            "saveAfter" : "toEdit",
            /*"addUrl" : "/bs/vote/voteInfo/insert",//新增
            "deleteUrl" : "/bs/vote/voteInfo/delete",//删除
            "updateUrl" : "/bs/vote/voteInfo/update",//修改*/
            "formDataUrl" : "/bs/vote/voteInfo/getDetail",//查询
            //"readonly2Label" : true //只读转文本
        };
        joForm.initFormPage(jParams);//初始化

    });
    //初始化新增页面回调函数(在初始化按钮前发生)
    joForm.initFormPageOfAdd = function(){

    };
    //初始化表单值前处理
    joForm.initFormValueBefore = function(oJson){
        oJson.startTime = jo.formatDate(oJson.startTime);
        oJson.endTime = jo.formatDate(oJson.endTime);
        oJson.createTime = jo.formatTime(oJson.createTime);
        oJson.updateTime = jo.formatTime(oJson.updateTime);
        if(oJson.voteResult){
            for(var k in oJson.voteResult){
                if(k == 'id'){
                    continue;
                }
                oJson[k] = oJson.voteResult[k];
            }
        }
        if(oJson.state == 1){
            oJson.state = '发起投票';
        }else if(oJson.state == 2){
            oJson.state = '管理员签名';
        }else if(oJson.state == 3){
            oJson.state = '计票中心计票';
        }
        oJson.voteTime = jo.formatTime(oJson.voteTime);
        oJson.adminSignTime = jo.formatTime(oJson.adminSignTime);
        oJson.countCenterTime = jo.formatTime(oJson.countCenterTime);
    };
    //初始化表单值后处理
    joForm.initFormValueAfter = function(oJson){
        //编辑页,根据投票主id查询选项信息列表
        if(!joForm.isAdd && joForm.params.PKValue){
            Grid('mainList').loadData("/bs/vote/voteOption/getList?voteId=" + joForm.params.PKValue);
        }
    };
    //新增请求提交前回调函数
    joForm.dealDataAtSaveBefore = function(oJson){

    };
    //修改请求提交前回调函数
    joForm.dealDataAtUpdateBefore = function(oJson){

    };
    /* 关于joForm更多回调函数和配置参数可查看jo-page-form.js */

    function trHandle(item){

        if(joForm.formData.voteResult.voteOptionId == item.id){
            item.optionContent = '<span style="color: green;font-weight: 700;">'+item.optionContent+' （投票结果）</span>';
        }

    }


    //表格渲染时行处理,参数1为当前行的数据对象,参数2为当前行的索引值(最小为0)
    joView.handleItem = function(oItem,iIndex){

    };
    //表格渲染完成后的回调,参数为表格数据(数组对象)
    joView.setGridDataAfter = function(oList){

    };

    /*function goVote(){
        var voteId = joForm.params.PKValue;//投票id
        if(!voteId){
            jo.showErrorMsg('投票ID无效');
            return;
        }
        var optionId = jo.getCheckBoxValue('optionId');//选项id
        if(!optionId){
            jo.showTipsMsg('请选择投票结果!');
            return;
        }
        var obj = {};
        for(var i=0;i<Grid('mainList').data.length;i++){
            var item = Grid('mainList').data[i];
            obj[item.id] = item.optionContent;
        }
        jo.confirm('您确定将票投给['+obj[optionId]+']吗?', function(idx){
            jo.postAjax('/bs/vote/voter/initiate', {voteId: voteId, optionId: optionId}, function(json){
                if(json && json.code == 0){
                    jo.showSuccessMsg('操作成功');
                }else if(json && json.info){
                    jo.showErrorMsg(json.info);
                }else{
                    jo.showErrorMsg('操作失败');
                }
            });
            jo.close(idx);
        });

    }*/
</script>
</body>
</html>
